home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / term43-source.lha / Extras / Source / gtlayout-Source.lha / LT_DeleteHandle.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-11  |  2.3 KB  |  121 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1994 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID LIBENT
  10. LT_DeleteHandle(REG(a0) LayoutHandle *Handle)
  11. {
  12.     if(Handle)
  13.     {
  14.         UnlockPubScreen(NULL,Handle -> PubScreen);
  15. #ifdef DO_CLONING
  16.         if(Handle -> CloneExtra)
  17.         {
  18.             if(Handle -> CloneExtra -> Screen)
  19.                 ScreenToBack(Handle -> CloneExtra -> Screen);
  20.         }
  21. #endif
  22.         if(Handle -> List)
  23.         {
  24.             struct Gadget    *Gadget;
  25.             ObjectNode    *Node;
  26.  
  27.             if(Handle -> Window)
  28.                 RemoveGList(Handle -> Window,Handle -> List,(UWORD)-1);
  29.  
  30.             Gadget = Handle -> List;
  31.  
  32.             if(Handle -> ExitFlush)
  33.             {
  34.                 while(Gadget)
  35.                 {
  36.                     if(GETOBJECT(Gadget,Node))
  37.                     {
  38.                         LTP_PutStorage(Node);
  39.  
  40.                         LTP_DeleteObjectNode(Handle,Node);
  41.                     }
  42.  
  43.                     Gadget = Gadget -> NextGadget;
  44.                 }
  45.             }
  46.             else
  47.             {
  48.                 while(Gadget)
  49.                 {
  50.                     if(GETOBJECT(Gadget,Node))
  51.                         LTP_DeleteObjectNode(Handle,Node);
  52.  
  53.                     Gadget = Gadget -> NextGadget;
  54.                 }
  55.             }
  56.  
  57.             FreeGadgets(Handle -> List);
  58.         }
  59.  
  60.         if(Handle -> Parent)
  61.             LT_UnlockWindow(Handle -> Parent);
  62.  
  63.         if(Handle -> Window)
  64.         {
  65.             LT_DeleteWindowLock(Handle -> Window);
  66.  
  67.             if(Handle -> MsgPort && Handle -> Window -> UserPort)
  68.             {
  69.                 struct IntuiMessage    *intuiMsg;
  70.                 struct Node        *next;
  71.  
  72.                 Forbid();
  73.  
  74.                 intuiMsg = (struct IntuiMessage *)Handle -> Window -> UserPort -> mp_MsgList . lh_Head;
  75.  
  76.                 while(next = intuiMsg -> ExecMessage . mn_Node . ln_Succ)
  77.                 {
  78.                     if(intuiMsg -> IDCMPWindow == Handle -> Window)
  79.                     {
  80.                         Remove(intuiMsg);
  81.  
  82.                         ReplyMsg(intuiMsg);
  83.                     }
  84.  
  85.                     intuiMsg = (struct IntuiMessage *)next;
  86.                 }
  87.  
  88.                 Handle -> Window -> UserPort = NULL;
  89.  
  90.                 ModifyIDCMP(Handle -> Window,NULL);
  91.  
  92.                 Permit();
  93.             }
  94.  
  95.             ClearMenuStrip(Handle -> Window);
  96.             CloseWindow(Handle -> Window);
  97.         }
  98.  
  99.         DisposeObject(Handle -> AmigaGlyph);
  100.         DisposeObject(Handle -> CheckGlyph);
  101.  
  102.         FreeScreenDrawInfo(Handle -> Screen,Handle -> DrawInfo);
  103.  
  104.         FreeVisualInfo(Handle -> VisualInfo);
  105.  
  106.         if(Handle -> RPort . Font && Handle -> CloseFont)
  107.             CloseFont(Handle -> RPort . Font);
  108. #ifdef DO_CLONING
  109.         if(Handle -> CloneExtra)
  110.         {
  111.             if(Handle -> CloneExtra -> Screen)
  112.                 CloseScreen(Handle -> CloneExtra -> Screen);
  113.         }
  114. #endif
  115.         if(Handle -> Pool)
  116.             AsmDeletePool(Handle -> Pool,SysBase);
  117.  
  118.         FreeMem(Handle,sizeof(LayoutHandle));
  119.     }
  120. }
  121.